package com.shi.yibanjia.common;

import com.shi.yibanjia.entity.po.User;
import lombok.Data;

@Data
public class UserContext {
    private static ThreadLocal<User> threadLocal = new ThreadLocal();

    public static User getUser() {
        return threadLocal.get();
    }

    public static void setUser(User user) {
        threadLocal.set(user);
    }

    public static void remove() {
        if (threadLocal.get() != null) {
            threadLocal.remove();
        }
    }
}
